<template>
  <view class="WdNavbar" :style="{ paddingTop: safeAreaInsets + 'rpx' }">
    <view class="title">{{ navbarTitle }}</view>
  </view>
</template>

<script>
export default {
  props: ['navbarTitle'],
  name: 'WdNavbar',
  data() {
    return {
      safeAreaInsets: 0
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      const { safeAreaInsets } = uni.getSystemInfoSync();
      this.safeAreaInsets = safeAreaInsets.top;
      if (this.safeAreaInsets > 0) {
        // 大于0那就是苹果手机
        this.safeAreaInsets = this.safeAreaInsets + 40;
        console.log(this.safeAreaInsets, '苹果端');
      } else {
        console.log(this.safeAreaInsets, 'H5端');
        this.safeAreaInsets = this.safeAreaInsets;
      }
    }
  }
};
</script>

<style lang="scss">
.WdNavbar {
  background-color: #fff;
  .title {
    font-family: PingFang SC, PingFang SC;
    font-weight: bold;
    font-size: 31rpx;
    color: #000000;
    line-height: 100rpx;
    text-align: center;
  }
}
</style>
